
function setCookie(name, val, day, path = "/") {
    if (day) {
        var date = new Date();
        date.setDate(date.getDate() + day)//在原本的日期上加7天
        document.cookie = name + "=" + val + ";expires=" + date.toUTCString() + ";path=" + path + ";"
    } else {
        document.cookie = name + "=" + val + ";expires" + ";path=" + path + ";"
    }
}




function getCookie(key, key1) {
    var cookie = document.cookie//获取cookie
    if (cookie) {
        var dataList = cookie.split("; ")//将字符串拆分成数组
        for (var i = 0; i < dataList.length; i++) {
            var item = dataList[i]//获取数组某项
            var arr = item.split('=')//将获取的数组某项拆分成一个数组长度位2的数组
            var name = arr[0]//获取某项cookie的键名
            var val = arr[1]//获取某项cookie的键值
            val = key1;
            if (key === name) {
                return val
            }
        }
    }
}
function updCookie(key, key1) {
    var cookie = document.cookie//获取cookie
    if (cookie) {
        var dataList = cookie.split("; ")//将字符串拆分成数组
        for (var i = 0; i < dataList.length; i++) {
            var item = dataList[i]//获取数组某项
            var arr = item.split('=')//将获取的数组某项拆分成一个数组长度位2的数组
            var name = arr[0]//获取某项cookie的键名
            var val = arr[1]//获取某项cookie的键值
            val = key1;
            if (key === name) {
                return val
            }
        }
    }
}
